export interface IMenuConfig {
  name: string;
  path: string;
  icon?: any;
  routes?: IMenuConfig[];
  screenUrl?: string;
  permission?: string;
  productId?: number;
}

export function getMenus() {
  const menus: IMenuConfig[] = [
    {
      name: "系统监控",
      path: `/sys`,
      icon: "BarsOutlined",
    },
    {
      name: "应用管理",
      path: `/application`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "应用列表",
          path: `/application/list`,
        }
      ]
    },
    {
      name: "配置管理",
      path: `/config`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "配置列表",
          path: `/config/list`,
        }
      ]
    },
    {
      name: "数据库管理",
      path: `/database`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "数据库表",
          path: `/database/table`,
        },
        {
          name: "数据库查询",
          path: `/database/sql-query`,
        }
      ]
    },
    {
      name: "kafka管理",
      path: `/kafka`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "kafka列表",
          path: `/kafka/list`,
        },
        {
          name: "kafka查询",
          path: `/kafka/query`,
        }
      ]
    },
    {
      name: "redis管理",
      path: `/redis`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "redis列表",
          path: `/redis/list`,
        },
        {
          name: "redis查询",
          path: `/redis/query`,
        }
      ]
    },
    {
      name: "租户管理",
      path: `/tenant`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "租户列表",
          path: `/tenant/1`,
        }
      ]
    },
    {
      name: "运维管理",
      path: `/opt`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "运维管理",
          path: `/opt/1`,
        }
      ]
    },
    {
      name: "平台管理",
      path: `/platform`,
      icon: "BarsOutlined",
      routes: [
        {
          name: "运维管理",
          path: `/platform/1`,
        },
      ]
    },
    {
      name: "系统日志",
      path: `/log`,
      icon: "BarsOutlined",
    }
  ];
  return menus;
}

export function getSelectedKeys(currentMenus: IMenuConfig[]) {
  if (!currentMenus || currentMenus.length === 0) {
    return [];
  }
  const path = currentMenus.length > 1 ? currentMenus[1].path : currentMenus[0].path;
  return [path]
}

export function getOpenKeys(currentMenus: IMenuConfig[]) {
  if (currentMenus && currentMenus.length > 0) {
    return [currentMenus[0].path]
  }
  return []
}

